Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Adrian 38 posts 117 karma points
    Feb 27, 2015 @ 12:47
    Adrian
    0

    Why do LogHelper methods take a "params Func<object>[] formatItems" arg?

    ..instead of params object[] formatItems

    The log4net adapter just converts the Func

  • Kevin Jump 2348 posts 14896 karma points MVP 8x c-trib
    Feb 27, 2015 @ 20:35
    Kevin Jump
    0

    I think - although i don't quite understand it - that by passing in Func<object>[] the values passed are not evaluated until they have to be, so for example if you have a load of Debug statements in your code - the parameters you are passing will only be evaluated if the logging level is set to debug ?

    so for example LogHelper.Debug<sometype>("the nubmer of things", ()=> item.Children.Count() ) 

    would not evaluate item.Children.Count() unless Debug is enabled in the config - meaning that the log lines are not detremental to performance when not needed.  

    That's why i think it does it. but I am sure some who actually understands it can shed more light on it. 

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies